package com.lyb;

import com.lyb.constant.SystemConstant;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

/**
 * 模拟操作系统启动类
 *
 * @author Mr.Alpaca Dayun
 * @version 1.4.0
 */
public class Main extends Application {
    public static void main(String[] args) {
        /* 启动模拟操作系统 */
        new Thread(new AlpacaSystem()).start();
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        try{
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(getClass().getResource("/view/main.fxml"));
            Parent root = loader.load();
            Scene scene = new Scene(root);
            scene.getStylesheets().add("/css/UI.css");
            primaryStage.setScene(scene);
            primaryStage.setTitle("主界面");
            primaryStage.setResizable(false);
            primaryStage.setOnCloseRequest(event -> {
                SystemConstant.ALPACA_COMMANDS.get(4).go(new String[]{"shutdown"});
            });
            primaryStage.show();
        }catch (IOException e){
            System.exit(400);
        }
    }
}
